//
//  MomentCommentCell+ConfigureForMomentItem.m
//  WeChatMoments
//
//  Created by Jiang on 2019/8/27.
//  Copyright © 2019 SilverFruity. All rights reserved.
//

#import "MomentCommentCell+ConfigureForMomentItem.h"
#import <YYText/YYText.h>

@implementation MomentCommentCell (ConfigureForMomentItem)
- (void)configureForMomentItem:(MomentItem *)item{
    // 拼接评论
    NSMutableAttributedString *text =  [NSMutableAttributedString new];
    for (CommentsItem *commentItem in item.comments) {
        NSString *string = [NSString stringWithFormat:@"%@: %@\n",commentItem.sender.nick,commentItem.content];
        NSRange range = [string rangeOfString:commentItem.sender.nick];
        NSMutableAttributedString *singleComment = [[NSMutableAttributedString alloc]initWithString:string];
        [singleComment yy_setTextHighlightRange:range color:[UIColor blueColor] backgroundColor:nil userInfo:nil];
        [text appendAttributedString:singleComment];
    }
    self.comentLabel.attributedText = text;
}
@end
